package com.cyz.web.app.responsibility;

public abstract class Handler {

    protected final static int NUM_ONE = 1;
    protected final static int NUM_THREE = 3;
    protected final static int NUM_SEVEN = 7;

    private int startNum;
    private int endNum;

    private Handler nexHandler;

    public Handler(int startNum) {
        this.startNum = startNum;
    }

    public Handler(int startNum, int endNum) {
        this.startNum = startNum;
        this.endNum = endNum;
    }

    public void setNexHandler(Handler nexHandler) {
        this.nexHandler = nexHandler;
    }

    protected abstract void handleLeave(LeaveRequest leave);

    public final void submit(LeaveRequest leave) {
        this.handleLeave(leave);
        if (this.nexHandler != null && leave.getNum() > this.endNum) {
            this.nexHandler.submit(leave);
        } else {
            System.out.println("流程结束");
        }


    }
}
